package model;

public class Menu {
	private String foodName;//鑿滃搧鍚嶇О
	private double price;//鑿滃搧鐨勪环鏍硷紱
	private int give;//鐐硅禐鏁帮紱
	
	public Menu(){
		
	}
	public Menu(String foodName,double price,int give){
		this.foodName = foodName;
		this.price = price;
		this.give = give;
	}
	
	//鏌ヨ鑿滃崟
	//浼犲弬
	//鍦ㄦ柟娉曚綋new鍑烘潵
	public void findAll(Sys sys){
		System.out.println("搴忓彿\t鑿滃搧鍚嶇О\t浠锋牸\t鐐硅禐鏁�");
		Menu[] menus = sys.getMenus();
		for (int i = 0; i < menus.length; i++) {
			if (menus[i] != null) {
				System.out.println((i+1)+"\t"+menus[i].getFoodName()+"\t"+menus[i].getPrice()+"\t"+menus[i].getGive());
			}
		}
		System.out.println("1銆佺偣椁怽t2銆佽繑鍥�");
		User user = new User();
		int choice = user.inputService();
		if (choice == 1) {
			System.out.println("璇疯緭鍏ヨ鐐圭殑鑿滅殑搴忓彿锛�");
			int mnum = user.inputMenu();
			//鎵惧埌杩欎釜鑿�
			String foodName = menus[mnum -1].getFoodName();
			double price = menus[mnum -1].getPrice();
			//鐢熸垚涓�涓鍗�
			Order order = user.inputOrder();
			order.setFoodName(foodName);
			order.setMoney(price*order.getFoodNum());
			Order[] orders = sys.getOrders();
			for (int i = 0; i < orders.length; i++) {
				if (orders[i] == null) {
					orders[i] = order;
					System.out.println("璁㈤鎴愬姛锛�");
					return;
				}
			}
			System.out.println("璁㈤澶辫触锛�");
		}
	}
	
	//鏄剧ず鑿滃崟
	public void findMenu(Sys sys){
		System.out.println("搴忓彿\t鑿滃搧鍚嶇О\t浠锋牸\t鐐硅禐鏁�");
		Menu[] menus = sys.getMenus();
		for (int i = 0; i < menus.length; i++) {
			if (menus[i] != null) {
				System.out.println((i+1)+"\t"+menus[i].getFoodName()+"\t"+menus[i].getPrice()+"\t"+menus[i].getGive());
			}
		}
	}
	
	public String getFoodName() {
		return foodName;
	}
	public void setFoodName(String foodName) {
		this.foodName = foodName;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public int getGive() {
		return give;
	}
	public void setGive(int give) {
		this.give = give;
	}
	
	
}
